|
1
|
|
|
/** |
|
2
|
|
|
* This file is part of the O2System Venus UI Framework package. |
|
3
|
|
|
* |
|
4
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
5
|
|
|
* file that was distributed with this source code. |
|
6
|
|
|
* |
|
7
|
|
|
* @author Steeve Andrian Salim |
|
8
|
|
|
* @copyright Copyright (c) Steeve Andrian Salim |
|
9
|
|
|
*/ |
|
10
|
|
|
// ------------------------------------------------------------------------ |
|
11
|
|
|
|
|
12
|
|
|
import * as $ from 'jquery'; |
|
13
|
|
|
import 'select2'; |
|
14
|
|
|
import 'bootstrap-select'; |
|
15
|
|
|
import 'selectize'; |
|
16
|
|
|
require('multiselect'); |
|
17
|
|
|
require('jquery.quicksearch'); |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Class Select |
|
21
|
|
|
* |
|
22
|
|
|
* @author Teguh Rianto |
|
23
|
|
|
* @package Components |
|
24
|
|
|
*/ |
|
25
|
|
|
export default class Select { |
|
26
|
|
|
constructor() { |
|
27
|
|
|
/** |
|
28
|
|
|
* Initiate select with search |
|
29
|
|
|
*/ |
|
30
|
|
|
this.selectWithSearch(); |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Initiate select insertable search |
|
34
|
|
|
*/ |
|
35
|
|
|
this.selectInsertableSearch(); |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Initiate select dropdown |
|
39
|
|
|
*/ |
|
40
|
|
|
this.selectDropdown(); |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Initiate select multi |
|
44
|
|
|
*/ |
|
45
|
|
|
this.selectMulti(); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
selectWithSearch() { |
|
49
|
|
|
$(".select-with-search").select2(); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
selectInsertableSearch() { |
|
53
|
|
|
$('.select-insertable-search').selectize({ |
|
54
|
|
|
create: true, |
|
55
|
|
|
sortField: 'text' |
|
56
|
|
|
}); |
|
57
|
|
|
|
|
58
|
|
|
$('.select-with-tags').selectize({ |
|
59
|
|
|
delimiter: ',', |
|
60
|
|
|
persist: false, |
|
61
|
|
|
create: function (input) { |
|
62
|
|
|
return { |
|
63
|
|
|
value: input, |
|
64
|
|
|
text: input |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
}); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
selectDropdown() { |
|
71
|
|
|
$('.select-dropdown').selectpicker(); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
selectMulti() { |
|
75
|
|
|
$('.multiselect-search').multiSelect({ |
|
76
|
|
|
selectableHeader: "<input type='text' class='search-input form-control mb-2' autocomplete='off' placeholder='Search...'>", |
|
77
|
|
|
selectionHeader: "<input type='text' class='search-input form-control mb-2' autocomplete='off' placeholder='Search...'>", |
|
78
|
|
|
afterInit: function(ms){ |
|
|
|
|
|
|
79
|
|
|
var that = this, |
|
80
|
|
|
$selectableSearch = that.$selectableUl.prev(), |
|
81
|
|
|
$selectionSearch = that.$selectionUl.prev(), |
|
82
|
|
|
selectableSearchString = '#'+that.$container.attr('id')+' .ms-elem-selectable:not(.ms-selected)', |
|
83
|
|
|
selectionSearchString = '#'+that.$container.attr('id')+' .ms-elem-selection.ms-selected'; |
|
84
|
|
|
|
|
85
|
|
|
that.qs1 = $selectableSearch.quicksearch(selectableSearchString) |
|
86
|
|
|
.on('keydown', function(e){ |
|
87
|
|
|
if (e.which === 40){ |
|
|
|
|
|
|
88
|
|
|
that.$selectableUl.focus(); |
|
89
|
|
|
return false; |
|
90
|
|
|
} |
|
91
|
|
|
}); |
|
92
|
|
|
|
|
93
|
|
|
that.qs2 = $selectionSearch.quicksearch(selectionSearchString) |
|
94
|
|
|
.on('keydown', function(e){ |
|
95
|
|
|
if (e.which == 40){ |
|
|
|
|
|
|
96
|
|
|
that.$selectionUl.focus(); |
|
97
|
|
|
return false; |
|
98
|
|
|
} |
|
99
|
|
|
}); |
|
100
|
|
|
}, |
|
101
|
|
|
afterSelect: function(){ |
|
102
|
|
|
this.qs1.cache(); |
|
103
|
|
|
this.qs2.cache(); |
|
104
|
|
|
}, |
|
105
|
|
|
afterDeselect: function(){ |
|
106
|
|
|
this.qs1.cache(); |
|
107
|
|
|
this.qs2.cache(); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
}); |
|
111
|
|
|
} |
|
112
|
|
|
} |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.